package online.inote.naruto.api.access.admin.modules.system.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.FieldNameConstants;
import online.inote.naruto.api.access.admin.modules.base.entity.SignatureEntity;

import javax.persistence.*;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * @description 系统服务实体对象
 * @author XQF.Sui
 * @date 2021/07/26 21:21
 */
@EqualsAndHashCode(callSuper = true)
@Data
@FieldNameConstants
@Entity
@Table(name = "naruto_system")
public class SystemEntity extends SignatureEntity {

  private static final long serialVersionUID = 56275026667591067L;

  @Id
  @Column(length = 36)
  @NotBlank(message = "ID不能为空")
  protected String id;

  @NotBlank(message = "系统名称不能为空")
  @Column(nullable = false, length = 64)
  private String name;

  @NotBlank(message = "系统英文名称不能为空")
  @Column(unique = true, nullable = false, length = 64)
  private String englishName;

  @NotNull(message = "是否启用不能为空")
  @Column(nullable = false, length = 1)
  private Boolean enable;

  @Column
  @JSONField(format = "yyyy-MM-dd")
  @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+08")
  private Date expireTime;

  @GeneratedValue
  @Column(nullable = false)
  @JSONField(format = "yyyy-MM-dd HH:mm:ss")
  @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08")
  private Date createTime;

  @Valid
  @Transient
  @NotNull(message = "管理人信息不能为空")
  private ManagerEntity manager;

  @Transient private String token;
  @Transient private String apiId;
  @Transient private Boolean isAuth;
  @Transient private Long authInterfaceNumber;
}
